///PHILOTES Source Code.  (C)2012 PhiloLabs
#pragma once

#ifndef _TextureManager_H__
#define _TextureManager_H__


#include "OgrePrerequisites.h"

#include "OgreResourceManager.h"
#include "OgreTexture.h"
#include "OgreSingleton.h"


namespace Ogre {

	
	
	
    class _OgreExport TextureManager : public ResourceManager, public Singleton<TextureManager>
    {
    public:

        TextureManager(void);
        virtual ~TextureManager();

        
        virtual ResourceCreateOrRetrieveResult createOrRetrieve(
            const String &name, const String& group, bool isManual = false,
            ManualResourceLoader* loader = 0, const NameValuePairList* createParams = 0,
            TextureType texType = TEX_TYPE_2D, int numMipmaps = MIP_DEFAULT, 
            Real gamma = 1.0f, bool isAlpha = false,
            PixelFormat desiredFormat = PF_UNKNOWN, bool hwGammaCorrection = false);

        
        virtual TexturePtr prepare( 
            const String& name, const String& group, 
            TextureType texType = TEX_TYPE_2D, int numMipmaps = MIP_DEFAULT, 
            Real gamma = 1.0f, bool isAlpha = false,
            PixelFormat desiredFormat = PF_UNKNOWN, bool hwGammaCorrection = false);

        
        virtual TexturePtr load( 
            const String& name, const String& group, 
            TextureType texType = TEX_TYPE_2D, int numMipmaps = MIP_DEFAULT, 
            Real gamma = 1.0f, bool isAlpha = false,
            PixelFormat desiredFormat = PF_UNKNOWN, 
			bool hwGammaCorrection = false);

        
        virtual TexturePtr loadImage( 
            const String &name, const String& group, const Image &img, 
            TextureType texType = TEX_TYPE_2D,
            int iNumMipmaps = MIP_DEFAULT, Real gamma = 1.0f, bool isAlpha = false,
            PixelFormat desiredFormat = PF_UNKNOWN, bool hwGammaCorrection = false);
			
        
        virtual TexturePtr loadRawData(const String &name, const String& group,
            DataStreamPtr& stream, ushort uWidth, ushort uHeight, 
            PixelFormat format, TextureType texType = TEX_TYPE_2D, 
            int iNumMipmaps = MIP_DEFAULT, Real gamma = 1.0f, bool hwGammaCorrection = false);

		
        virtual TexturePtr createManual(const String & name, const String& group,
            TextureType texType, uint width, uint height, uint depth, 
			int num_mips, PixelFormat format, int usage = TU_DEFAULT, ManualResourceLoader* loader = 0,
			bool hwGammaCorrection = false, uint fsaa = 0, const String& fsaaHint = StringUtil::BLANK);
			
        
        TexturePtr createManual(const String & name, const String& group,
            TextureType texType, uint width, uint height, int num_mips,
            PixelFormat format, int usage = TU_DEFAULT, ManualResourceLoader* loader = 0,
			bool hwGammaCorrection = false, uint fsaa = 0, const String& fsaaHint = StringUtil::BLANK)
		{
			return createManual(name, group, texType, width, height, 1, 
				num_mips, format, usage, loader, hwGammaCorrection, fsaa, fsaaHint);
		}

        
        virtual void setPreferredIntegerBitDepth(ushort bits, bool reloadTextures = true);

        
        virtual ushort getPreferredIntegerBitDepth(void) const;

        
        virtual void setPreferredFloatBitDepth(ushort bits, bool reloadTextures = true);

        
        virtual ushort getPreferredFloatBitDepth(void) const;

        
        virtual void setPreferredBitDepths(ushort integerBits, ushort floatBits, bool reloadTextures = true);

		
		virtual bool isFormatSupported(TextureType ttype, PixelFormat format, int usage);

		
		virtual bool isEquivalentFormatSupported(TextureType ttype, PixelFormat format, int usage);

		
		virtual PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage) = 0;

        
        virtual bool isHardwareFilteringSupported(TextureType ttype, PixelFormat format, int usage,
            bool preciseFormatOnly = false) = 0;

        
        virtual void setDefaultNumMipmaps(size_t num);

        
        virtual size_t getDefaultNumMipmaps()
        {
            return mDefaultNumMipmaps;
        }

        
        static TextureManager& getSingleton(void);
        
        static TextureManager* getSingletonPtr(void);

    protected:

        ushort mPreferredIntegerBitDepth;
        ushort mPreferredFloatBitDepth;
        size_t mDefaultNumMipmaps;
    };
	
	
}// Namespace

#endif
